package com.drakulo.hi.logic.actions.conditions;

import com.dk.hi.core.SwitchManager;

/**
 * <p>
 * Switch condition
 * </p>
 * <p>
 * This condition is associated to a global switch witch may be turned ON or
 * OFF.
 * </p>
 */
public class SwitchCondition implements Condition {
	/**
	 * Switch global id
	 */
	private Integer switchId;

	/**
	 * State of the switch needed in order to pass the condition test
	 */
	private boolean neededState;

	/**
	 * Constructor
	 * 
	 * @param switchId
	 *            - Switch global id
	 * @param neededState
	 *            - needed state for the condition
	 */
	public SwitchCondition(Integer switchId, Boolean neededState) {
		this.switchId = switchId;
		this.neededState = neededState;
	}

	/** {@inheritDoc} */
	public boolean test() {
		return SwitchManager.getStateOf(this.switchId) == this.neededState;
	}

}
